<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*
      Object.getOwnPropertyNames()返回一个数组，该数组对元素是obj`自身拥有的枚举或不可枚举属性名称字符串
      */
      let arr = ['a', 'b', 'c'];
      console.log(Object.getOwnPropertyNames(arr).sort()); // ["0", "1", "2", "length"]

      // 类数组对象
      let obj = { 0: 'a', 1: 'b', 2: 'c' };
      console.log(Object.getOwnPropertyNames(obj).sort()); // ["0", "1", "2"]
    </script>
  </body>
</html>
